home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Night Owl 6
/
Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso
/
009a
/
autofc20.zip
/
LEDIT.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1991-01-26
|
5KB
|
209 lines
UNIT ledit;
INTERFACE
uses dos,crt;
procedure beep;
function edit(f3:string;len:integer):string;
IMPLEMENTATION
procedure beep;
begin
sound(440);
delay(100);
nosound;
end;
function edit(f3:string;len:integer):string;
var
xpos,ypos,ch_int,ch1_int,
basex,basey,ins_flg,i : integer;
ch,ch1 : char;
blanks : string;
chx : string[1];
regs : registers;
top_scan, bot_scan,small_scan : byte;
begin
if len = 0 then len := 255; {set to maximum}
{get the cursor configuration}
regs.ah := $0f; {get display columns(ah),mode(al), page(bh)}
intr($10,regs);
regs.ah := 3; {get cursor configuration ch = start scan line, cl = end}
intr($10,regs); {dh = row, dl = column. Page is in bh from previous intr}
bot_scan := regs.cl;
top_scan := regs.ch;
small_scan := bot_scan - 1;
regs.ch := small_scan; {default to two scan line cursor}
regs.cl := bot_scan;
ins_flg := 0; {start in no insert mode}
blanks := '';
for i := 1 to len do blanks := blanks + ' ';
if length(f3) > len then f3[0] := chr(len);
while length(f3) < len do
begin
f3 := f3+ ' ';
end;
ypos := wherey;
xpos := 1;
basey := ypos;
basex := wherex;
write(f3,'|');
gotoxy(basex + xpos - 1,ypos);
repeat
ch := readkey;
ch_int := ord(ch);
case ch_int of
0 : {special charactre}
begin
ch1 := readkey;
ch1_int := ord(ch1);
case ch1_int of
71:
begin
xpos := 1;
gotoxy(basex + xpos -1,basey);
end;
79:
begin
xpos := len;
gotoxy(basex + xpos -1,basey);
end;
75:
begin
if basex + xpos - 1 > basex then
xpos := xpos-1
else
beep
end;
77:
begin
if basex + xpos + 1 <= basex+len then
xpos := xpos+1
else
beep
end;
82: {insert button - toggle insert mode}
begin
if ins_flg = 0 then
begin
ins_flg := 1;
regs.ch := $0;
regs.cl := bot_scan;
end
else
begin
ins_flg := 0;
regs.ch := small_scan;
regs.cl := bot_scan;
end;
regs.ah := $01; {cursor function}
intr($10,regs); {change the cursor}
end;
83: {delete character}
if f3 <> blanks then
begin
delete(f3,xpos,1);
f3 := f3 + ' '; {keep len characters}
gotoxy(basex,basey);
write(f3);
gotoxy(basex + xpos -1,ypos);
end
else
begin
beep;
end;
end;
gotoxy(basex + xpos - 1,ypos)
end; {of special character}
else
begin
case ch_int of
008: {backspace}
begin
if basex +xpos -1 > basex then
begin
f3[xpos-1] := ' ';
dec(xpos);
gotoxy(basex,basey);
write(f3);
gotoxy(basex + xpos -1,ypos);
end
else
begin
beep;
end;
end;
013: {return}
begin
{nothing}
end;
027: {escape}
begin
f3 := blanks; {set to blanks - will empty below}
gotoxy(basex,basey);
write(blanks);
gotoxy(basex,basey);
xpos := 1;
end;
else {not backspace, escape, or <cr>}
if ins_flg = 0 then {overwrite}
begin
write(ch);
f3[xpos] := ch;
if basex + xpos + 1 <= basex + len then
begin
inc(xpos);
end
else
begin
gotoxy(basex + xpos -1,ypos);
beep;
end;
end
else {insert}
begin
{if last char is blank and not end}
if (f3[len] = ' ') and (xpos < len) then
begin
delete(f3,len,1);
insert(ch,f3,xpos);
gotoxy(basex,basey);
write(f3);
inc(xpos);
gotoxy(basex + xpos -1,ypos);
end
else
begin
beep;
end; {of last char blank test}
end; {of insert modes}
end; {case of not backspace or <cr>}
end; {case of regular characters}
end; {of cases of keyboard character}
until ch_int = 13;
{ gotoxy(1,22);
write('new description: ',f3);}
while f3[length(f3)] = ' ' do {strip trailing blanks}
begin
delete(f3,length(f3),1);
end;
edit := f3;
regs.ch := top_scan; {Whatever cursor}
regs.cl := bot_scan; {mode we started}
regs.ah := $1; {in, put it back}
intr($10,regs);
end; {function}
end. {unit}